Skip to content

fix(id/web): validate collab AUTH_OK/NEW_VERSION frame fields (#7854) - #8712

Merged
dezren39 merged 1 commit into
mainfrom
queue/14122-7854-collab-frame-fields
Nov 11, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/14122-7854-collab-frame-fields

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #7854.

handleMessage in pkgs/id/web/src/collab.ts shape-trusted two server frames whose fields flow into persisted state:

  • AUTH_OK: any truthy msg[3] was adopted as the refreshed token — written to currentToken (re-sent on every reconnect) and passed to onTokenRefresh, whose saveIdentity persists it via String(value): a numeric token persisted as "12345", an object as "[object Object]", overwriting the valid stored token.
  • NEW_VERSION: msg[1] was passed unchecked to onNewVersion, whose callback writes it into dataset.hash — the value the next save posts as the document hash.

Both frames now validate at the boundary, following the INIT (#2824) and CURSOR (#7873) pattern in the same switch: a refreshed token is adopted only when it is a non-empty string; onNewVersion fires only when hash and name are strings. Malformed frames are logged and dropped, leaving the current token, the stored identity, and dataset.hash untouched.

Tests (named oracle: the frame-field validation contract): AUTH_OK with a numeric token and with an object token (assert onTokenRefresh never fires and the reconnect AUTH frame still carries the previous token), NEW_VERSION with an object hash (assert onNewVersion never fires), plus the well-formed controls.

Verified locally: collab.test.ts 38/38 pass. Full web suite: 787 passed, 1 failure in search-panel.test.ts ("Replace all matches" aria-label) that reproduces identically on clean main — pre-existing and unrelated.

Queue task 14122, lane code-c. Issue triaged inline in the same claim (note on #7854).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

handleMessage shape-trusted the AUTH_OK refreshed token and the NEW_VERSION hash: a numeric/object token was adopted verbatim, persisted over the valid stored identity via String(value), and re-sent on every reconnect; a non-string hash became [object Object] in dataset.hash. Both frames now validate at the boundary (the INIT #2824 / Cursor #7873 pattern): a token is adopted only when a non-empty string, NEW_VERSION fires only for string hash and name; malformed frames are logged and dropped with current state untouched. Regression tests cover numeric/object tokens (reconnect still sends the old token) and an object hash, plus controls. collab.test.ts 38/38; full web suite 787 pass with one pre-existing search-panel failure reproduced on clean main.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 14:45
@dezren39

Copy link
Copy Markdown
Member Author

@codex review

New PR for #7854: boundary validation for collab AUTH_OK/NEW_VERSION frame fields. Please review head c50c42e. (Queue worker lane code-c, task 14122.)

@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 06506925-919c-4026-89f4-9855255ac46e
Commits

Reviewing files that changed from the base of the PR and between f3229cc and c50c42e.

Files selected for processing: 2

  • pkgs/id/web/src/collab.test.ts
  • pkgs/id/web/src/collab.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T14:47:16.161757Z c50c42e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: c50c42e09f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit 4e98c5e into main Nov 11, 2026
3 of 21 checks passed
@dezren39
dezren39 deleted the queue/14122-7854-collab-frame-fields branch November 11, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant